package main

import (
	"crypto/tls"
	"fmt"
	"golang.org/x/net/http2"
	"io"
	"net/http"
	"time"
)

//var url = "https://localhost:8080"

var url = "https://localhost:8080/1" //

func main() {
	request2()
}

func request2() {
	//path, _ := os.Getwd()
	client := &http.Client{
		Timeout: 100 * time.Millisecond,
	}

	tlsConfig := &tls.Config{
		//设置安全跳跃认证
		InsecureSkipVerify: true,
	}
	client.Transport = &http2.Transport{
		TLSClientConfig: tlsConfig,
	}
	resp, err := client.Get(url)
	if err != nil {
		fmt.Printf("Failed get: err:%s \n", err)

		return
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Printf("Failed reading response body: %s\n", err)
		return
	}
	//fmt.Printf("Get request2 response %d: \n %s \n  %s \n", resp.StatusCode, resp.Proto, string(body))
	fmt.Printf("resp.StatusCode: %d \n", resp.StatusCode)
	fmt.Printf("resp.Proto:  %s \n", resp.Proto)
	fmt.Printf("body: %s \n", string(body))
}
